/*
Copyright (c) 2010 Tiana RAZAFINDRALAMBO

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

package;

class Curl 
{ 		
	public static inline function init(url:String = null):String
	{		
		return untyped __call__("curl_init", url);
	}
	public static inline function errno(resource:String):Int
	{
		return untyped __call__("curl_errno", resource);
	}
	
	public static inline function copy_handle(resource:String):String
	{
		return untyped __call__("curl_copy_handle", resource);
	}
	public static inline function close(resource:String)
	{
		return untyped __call__("curl_close", resource);
	}	 
	
	public static inline function exec(resource:String):String
	{ 
		var val = untyped __call__("curl_exec", resource); 
		return ((!val)?null:(cast val));
	}
		
	public static inline function setopt(resource:String, option:String, value:Dynamic):Bool
	{
		return untyped __call__("curl_setopt", resource, untyped __php__(option), value);
	}
	
	public static inline function getinfo(resource:String):Dynamic
	{
		return untyped __call__("curl_getinfo", resource);
	}
	
	public static inline function error(resource:String):String
	{
		return untyped __call__("curl_error", resource);
	}
	public static inline function multi_add_handle(resourceA:String, resourceB:String)
	{
		return untyped __call__("curl_multi_add_handle", resourceA, resourceB);
	}	
	public static inline function multi_close(resource:String)
	{	
		return untyped __call__("curl_multi_close", resource);
	}
	public static inline function multi_exec(resource:String, still_running:Int=null)
	{
		return untyped __call__("curl_multi_exec", resource, still_running);
	}
	public static inline function multi_getcontent(resource:String)
	{
		return untyped __call__("curl_multi_getcontent", resource);
	}
	public static inline function multi_info_read(resource:String, msgs_in_queue:Int = null)
	{
		return untyped __call__("curl_multi_info_read", resource, msgs_in_queue);
	}
	public static inline function multi_init()
	{
		return untyped __call__("curl_multi_init");
	}
	public static inline function multi_remove_handle(resourceA:String, resourceB:String)
	{
		return untyped __call__("curl_multi_init", resourceA, resourceB);
	}
	public static inline function multi_select(resource:String, timeout:Float = 1.0)
	{
		return untyped __call__("curl_multi_select", resource, timeout);
	}
	public static inline function multi_setopt_array(resource:String, array:Dynamic)
	{
		return untyped __call__("curl_multi_setopt_array", resource, array);
	}
}
